let appDn_baseDir = 'hiker://files/rules/dzHouse/dzMovie/';//初始化app影视断插版的基础文件目录
let appDn_jsName = 'appmovie_dp.js';//初始化app影视插件名
if(!getVar('appDp.bs')){
    putVar('appDp.bs',appDn_baseDir);
}
if(!getVar('appDp.js')){
    putVar('appDp.js',appDn_baseDir+appDn_jsName);
}
var Gheaders = {"User-Agent":"Dart/2.13 (dart:io)"};
var global_headers = {headers:Gheaders};
var extra_headers = ';get;utf-8;{User-Agent@Dart/2.13 (dart:io)}'; //只能用于二级传递,不可以fetch使用
//列表乱序函数
function randomSort(arr) {
    arr.sort(function(a, b) {
        return Math.random() - 0.5;
    });
    return arr;
}
// 通用发送仓库post请求
function req(url,data) {
    let result = request(url, {
        headers: {
            'content-type': 'application/json'
        },
        body: JSON.stringify(data),
        method: 'POST'
    });
    // log('result:'+result);
    return JSON.parse(result).result;
}
// log('准备加载主界面...');
//自定义工具
let Tools = {
    'unique2': function (arr){
  return arr.filter(function(item, index, arr) {
    //当前元素，在原始数组中的第一个索引==当前索引值，否则返回当前元素
    return arr.indexOf(item, 0) === index;
  });
    }
}
function appDpHome() { // app影视断插版1级解析
    let d = [];
    const {color,small} = $.require("hiker://page/utiliy?rule=道长仓库Pro");
    let self = MY_RULE.title; // 取自己规则的标题
    let search_mode = getItem('appDp.search_mode','聚合');
    let search_xc = getItem('appDp.search_xc','10');
    let load_file = getVar("appDp.now_file")?getVar("appDp.now_file"):'m点佬.txt';
    let html = MY_URL.indexOf("hiker://empty")>-1?fetch(getVar("appDp.bs")+load_file):getResCode();
    html = /http/.test(html) ? html:base64Decode(html);
    let arr = html.match(/#[\s\S]*?#/g);
    let count = html.match(/[\S]*?,.*?[\s]/g).length;
    // log(arr);
    log(1);
    d.push({
        title:'🔄更新:'+'(共' + color(count,'#ff7000') + '个)',
        col_type:'scroll_button',
        url:$().lazyRule(()=>{
            let code = fetch(getVar('appDp.js_web'));
            if(!/setResult/.test(code)){
                return 'toast://更新失败，网络不好或者服务器抽风'
            }else{
                eval(fetch(getVar("appDp.js")));
                uploadFiles(2);
                writeFile(getVar('appDp.js'),code);
                refreshPage(true);
                return 'toast://已更新'
            }
        })
    });
    log(2);
    d.push({
        title:'🕒'+color(getItem('appDp.timeout','5000'),'#ff7000'),
        col_type:'scroll_button',
        url:$(getItem('appDp.timeout','5000'),'请输入解析超时毫秒').input(()=>{
            if(!parseInt(input)){
                return 'toast://超时设置错误，拒绝保存'
            }
            if(input===getItem('appDp.timeout','5000')){
                return 'toast://似乎没啥变化~'
            }
            setItem('appDp.timeout',input||'5000');
            refreshPage(true);
            return 'toast://已设置解析超时毫秒:'+getItem('appDp.timeout','5000');
        }),
    });
    log(3);
    d.push({
        title:color('帮助','#ff7000'),
        col_type:'scroll_button',
        url:$('请认真阅读,不能错过任何细节!').confirm(()=>{
            return $().rule(()=>{
                let d = [];
                let msg  = fetch('http://hiker.nokia.press/hikerule/zyw_data/9');
                d.push({
                    title:msg,
                    col_type:'rich_text'
                });
                setResult(d);
            });
        }),
    });
log(4);
    function searchToolsInit(){
        let base_search_js = 'hiker://files/rules/dzHouse/js/搜索引擎切换.js';
        if(!fetch(base_search_js)){
            writeFile(base_search_js,fetch('http://hiker.nokia.press/hikerule/rulelist.json?id=1676'));
        }
        return eval(fetch(base_search_js).replace(base64Decode("QGpzOg=="),""))
    }
    log(5)
    d.push({
        title:"🔍"+getItem('home.search_api','空白'),
        col_type:'scroll_button',
        url:searchToolsInit(),
    });
log(6)
    d.push({
        title: '⚙️设置(' + search_mode+')[' + search_xc+']',
        url:$('hiker://empty#noRecordHistory#').rule(()=>{
            let d=[];
            d.push({
                title: '搜索功能设置',
                col_type: 'text_center_1',
                url: 'hiker://empty'
            });
            d.push({
                title: '模式' + '(' + getItem('appDp.search_mode','聚合') + ')',
                url: $().lazyRule(() => {
                    if(getItem('appDp.search_mode','聚合')==='聚合'){
                        setItem('appDp.search_mode','列表')
                    }else{
                        setItem('appDp.search_mode','聚合')
                    }
                    refreshPage(true);
                    return 'toast://已设置搜索模式为:'+getItem('appDp.search_mode','聚合');
                }),
                col_type: 'flex_button'
            });
            d.push({
                title: '线程' + '(' + getItem('appDp.search_xc','10') + ')',
                url: $(getItem('appDp.search_xc','10'),'请设置搜索线程').input(() => {
                    if(!parseInt(input)){
                        return 'toast://输入有误,暂未保存'
                    }
                    setItem('appDp.search_xc',input);
                    refreshPage(true);
                    return 'toast://已设置搜索线程为:'+getItem('appDp.search_xc','10');
                }),
                col_type: 'flex_button'
            });

            d.push({
                title: '🕒超时('+getItem("appDp.search_timeout","5000")+')',
                url: $(getItem("appDp.search_timeout","5000"), "输入搜索返回超时[毫秒]\n最低1000").input(() => {
                    let now_set = (parseInt(input)!==0&&!parseInt(input))?'5000':input;
                    if(parseInt(now_set)<1000){
                        now_set = '1000';
                    }
                    setItem('appDp.search_timeout', now_set);
                    let tips = '已设置搜索超时为:'+now_set+'豪秒';
                    refreshPage(true);
                    return 'toast://'+tips;
                }),
                col_type: 'flex_button'
            });
            d.push({
                title: '特殊功能设置(资源同步时间间隔,app展示模式)',
                url: 'hiker://empty',
                col_type: 'text_center_1'
            });
            let order_tips = getItem('appDp.random')==='1'?'💫随机显示顺序':'🍄固定顺序';
            d.push({
                title: order_tips,
                url: $().lazyRule(() => {
                    if(getItem('appDp.random')==='1'){
                        setItem('appDp.random', '0');
                    }else{
                        setItem('appDp.random', '1');
                    }
                    let tips = getItem('appDp.random')==='1'?'💫随机显示顺序':'🍄固定顺序';
                    refreshPage(true);
                    return 'toast://已设置app显示及搜索顺序为:'+tips;
                }),
                col_type: 'flex_button'
            });
            d.push({
                title: '⏰自动同步资源间隔天数:'+getItem("appDp.upload_days","1"),
                url: $(getItem("appDp.upload_days","1"), "输入自动同步资源间隔天数,为0关闭同步").input(() => {
                    setItem("appDp.upload_days",input);
                    let tips = input==='0'?'已关闭同步':'已设置同步间隔为:'+input+'天';
                    refreshPage(true);
                    return 'toast://'+tips;
                }),
                col_type: 'flex_button'
            });
            d.push({
                title: '接口文件管理(支持app,app.v1,tv接口)',
                url: 'hiker://empty',
                col_type: 'text_center_1'
            });
            d.push({
                title: '打开编辑',
                url: $().lazyRule(() => {
                    let load_file = getVar("appDp.now_file")?getVar("appDp.now_file"):'m点佬.txt';
                    return 'editFile://'+getVar("appDp.bs")+load_file;
                }),
                col_type: 'text_2'
            });

            d.push({
                title: '编码/解码',
                url: $().lazyRule(() => {
                    let load_file = getVar("appDp.now_file")?getVar("appDp.now_file"):'m点佬.txt';
                    let file_path = getVar("appDp.bs")+load_file;
                    let file_code = fetch(file_path)||"";
                    let mode = file_code.indexOf('http')>-1?'编码':'解码';
                    file_code = mode==='解码'?base64Decode(file_code):base64Encode(file_code);
                    writeFile(file_path, file_code);
                    return 'toast://'+mode+'成功。';
                }),
                col_type: 'text_2'
            });
            setResult(d);
        }),
        col_type: 'scroll_button'
    });
log(7);
    let search_rule = getItem('home.search_rule','');
    let search_api = getItem('home.search_api','空白');
    d.push({
        title: '搜索',
        desc: "请输入搜索关键词",
        extra: {
            onChange: "putVar('appDp.searchText',input)",
            titleVisible: true,
            defaultValue:getVar('appDp.searchText',''),
        },
        url:$.toString((search_rule,search_api) => {
            // var link = 'hiker://empty#noRecordHistory#$$$' + input + '$$$fypage$$$';
            // return $(link).rule(() => {
            //     // eval(fetch(getVar("js_dir")));
            //     // app_search();
            //     let d=[];
            //     d.push({
            //         title:'啥也不是',
            //         col_type:'text_1'
            //     })
            //     setResult(d);
            // });
            if(/空白/.test(search_api)){
                // let tips = '大哥别搜了吧,这个功能我还没开写呢.\n具体请看使用须知';
                // // return 'toast://'+tips;
                // return $(tips).confirm();
                let link = 'hiker://empty#noRecordHistory#$$$' + input + '$$$fypage$$$';
                return $(link).rule(() => {
                    let jsCode = fetch(getVar('appDp.js'));
                    eval(jsCode);
                    appDpSearch();
                });
            }else{
                let search_word = getVar('appDp.searchText');
                let ret = search_word?'hiker://search?s='+search_word+'&rule='+search_rule:'hiker://search';
                log('搜索:'+search_word+',链接:'+ret);
                return ret;
            }

        },search_rule,search_api),
        col_type: "input"
    });
log(8);
    let datas = []; //用于统计分类下的规则名称json，没啥用
    for (let i in arr) {
        let tabs = arr[i].match(/#.*?[\s]/g)[0].split('#')[1].replace(/\n/, '');// 分类页面名称如app影视/tv影视/appV1
        let list = arr[i].match(/[\S]*?,.*?[\s]/g);
        d.push({
            title: tabs + ' ' + list.length,
            url: 'hiker://empty',
            col_type: 'text_1'
        });
        if (getItem('appDp.random', '1') === '1') {
            list = randomSort(list);
        }
        for (let j in list) {
            let img = list[j].split(',').length >= 3 ? list[j].split(',')[2].replace('\n', '') : '';
            let title = list[j].split(',')[0];
            let turl = list[j].split(',')[1].replace(/[\s]/g, '');
            let url = 'hiker://empty';
            datas.push({
                title: title,
                url: turl,
                img: img
            });
            if (/TV影视/.test(tabs)) {
                url = 'hiker://empty$$' + tabs + '$$' + turl + '$$?ac=list&class=&page=fypage&area=&type=&start=$$fypage';
            }else if (/APP影视/.test(tabs)) {
                if (/api\.php\/app/.test(turl)) {
                    url = 'hiker://empty$$' + tabs + '$$' + turl + '$$index_video?token=$$fypage';
                } else if (/xgapp\.php\/v1/.test(turl)) {
                    url = 'hiker://empty$$' + tabs + '$$' + turl + '$$index_video?token=$$fypage';
                } else {
                    url = 'hiker://empty$$' + tabs + '$$' + turl + '$$/vodPhbAll$$fypage';
                }
            }
            d.push({
                title: title,
                pic_url: img,
                url: url,
                col_type: 'icon_round_small_4'
            });
        }
    }
log(9)
    d = d.concat([
        {col_type:'line_blank'},
        {title:'',col_type: 'text_center_1',url:'hiker://empty'}
    ]);
    log(10);
    setResult(d);
}

function appDpEj(){//APP二级解析代码
    const {color, small} = $.require("hiker://page/utiliy?rule=道长仓库Pro");
    let d = [];
    let movieType = MY_URL.split('$$')[1]; //类别:APP影视,APP影视v1,TV影视
    let api = MY_URL.split('$$')[2]; // 接口地址 murl
    let data_url = api + MY_URL.split('$$')[3]; //完整数据访问网页地址 tyurl
    let Npage = MY_URL.split('$$')[4]; //传进来的页数
    // log('当前传进来的页数:'+Npage);
    let type_names = [];//分类名称列表 typt
    let type_keys = [];//分类替换词列表 typl
    let index_url = '';//app访问数据首页完整地址
    log(20);
    addListener('onClose', $.toString(()=>{
        clearVar("appDp.now_type_name");
        clearVar("appDp.class");
        clearVar("appDp.area");
        clearVar("appDp.lang");
        clearVar("appDp.year");
        clearVar("appDp.first_type_id");
    }));
    log(21);
    if (/TV影视/.test(movieType)) {
    log(22)
        if (parseInt(Npage)===1) {//第一页渲染分类
            // 'https://api.diliktv.xyz/api.php/Chengcheng/vod/?ac=list&class=&page=1&area=&type=&start='
            // 'https://api.diliktv.xyz/api.php/Chengcheng/vod/?ac=list&class=movie&page=1&area=&type=&start='
            // https://api.diliktv.xyz/api.php/Chengcheng/vod/?ac=list&class=&page=1&area=&type=&start=
            type_names = '电影&连续剧&综艺&动漫'.split('&');//分类列表
            type_keys = 'movie&tvplay&tvshow&comic'.split('&');//分类替换词
            for (let i in type_keys) {
                index_url = api + '?ac=list&class=' + type_keys[i] + '&page=fypage&area=&type=&start=';
                d.push({
                    title: type_names[i],
                    url: $(index_url).rule((api,tvlistdata) => {
                        let d=[];
                        let html = JSON.parse(getResCode());
                        d = tvlistdata(api,html);
                        setResult(d);
                    }, api,tvlistdata),
                    col_type: 'flex_button'
                })
            }
            d.push({
                col_type: 'line'
            });
        }
        try {
            let html = JSON.parse(fetch(data_url));
            d = d.concat(tvlistdata(api,html));
        } catch (e) {log(e.message)}
log(23)
    } else if (/APP影视/.test(movieType)) {
    log(24)
        let typcode = '';//取分类列表返回的字符串json
        let typec = ''; //分类取出来的json列表
        let reqUrl = ''; //请求地址
        try {
            if(parseInt(Npage)===1) {
            log(25)
                reqUrl = /api\.php\/app|xgapp\.php\/v1/.test(api) ? api + "nav?token=" : api + "/types";
                typcode = request(reqUrl, global_headers); //取分类列表
                if (/检测中/.test(typcode)) {
                log(50)
                    typcode = fetch(reqUrl + '&btwaf' + typcode.match(/btwaf(.*?)\"/)[1], {});
                    log(51)
                }
                log(40)
                let backJson = JSON.parse(typcode);
                if (/api\.php\/app/.test(api)) {
                log(52)
                    typec = backJson.list
                    log(53)
                } else if (/xgapp\.php\/v1/.test(api)) {
                log(54)
                    typec = backJson.data;
                    log(55)
                } else {
                log(56)
                    typec = backJson.data.list;
                    log(57)
                }
log(41)
                let first_type_name = typec[0].type_name;//第一个大类别的类别名称
                let first_type_id = typec[0].type_id;//第一个大类别的类别ID
                putVar('appDp.first_type_id',first_type_id+''); //将id设为变量
log(26)
                //类别----------------------------------
                type_names = typec.map((it) => {
                    return {
                        title: it.type_name === getVar('appDp.now_type_name', first_type_name) ? color(it.type_name, '#5FB878') : it.type_name,
                        url: $().lazyRule((it) => {
                            putVar('appDp.type_id', it.type_id);
                            putVar('appDp.now_type_name', it.type_name);
                            refreshPage(true);
                            return 'hiker://empty'
                        }, it),
                        col_type: 'scroll_button'
                    }
                });
                // 类别的第一个元素默认加个类别:
                type_names[0].title = color('类别:', '#5FB878') + type_names[0].title;
                let types_data = type_names.concat([{col_type: 'line'}]);
                //--------------------------

                let now_type_extend = typec.filter(it => it.type_name === getVar('appDp.now_type_name', first_type_name))[0].type_extend;
                let first_class = now_type_extend.class.split(',')[0] || '';
                let first_area = now_type_extend.area.split(',')[0] || '';
                let first_lang = now_type_extend.lang.split(',')[0] || '';
                let first_year = now_type_extend.year.split(',')[0] || '';
log(27)
log(now_type_extend)
                // log("额外筛选");
                //------类型-----------------------------
                let tclass_data = Tools.unique2(now_type_extend.class.split(',')).map((it) => {
                    return {
                        // title:it===getVar('appDp.class',first_class)?color(it,'#5FB878'):it,
                        title: it === getVar('appDp.class', '') ? color(it, '#5FB878') : it,
                        url: $().lazyRule((it) => {
                            putVar('appDp.class', it);
                            refreshPage(true);
                            return 'hiker://empty'
                        }, it),
                        col_type: 'scroll_button'
                    }
                });
                log(80);
                let tclass_head = [{
                    title: getVar('appDp.class', '') === '' ? color('类型:全部', '#5FB878') : color('类型:', '#5FB878') + '全部',
                    url: $().lazyRule(() => {
                        clearVar('appDp.class');
                        refreshPage(true);
                        return 'hiker://empty'
                    }),
                    col_type: 'scroll_button'
                }];
                tclass_data = tclass_data.length > 1 ? tclass_head.concat(tclass_data).concat([{col_type: 'line'}]) : [];
                // log('类型');
                //----------------------------------------
log(28)
                //-------------------区域
                let tarea_data = Tools.unique2(now_type_extend.area.split(',')).map((it) => {
                    return {
                        // title:it===getVar('appDp.area',first_area)?color(it,'#5FB878'):it,
                        title: it === getVar('appDp.area', '') ? color(it, '#5FB878') : it,
                        url: $().lazyRule((it) => {
                            putVar('appDp.area', it);
                            refreshPage(true);
                            return 'hiker://empty'
                        }, it),
                        col_type: 'scroll_button'
                    }
                });
                log(29);
                let tarea_head = [{
                    title: getVar('appDp.area', '') === '' ? color('地区:全部', '#5FB878') : color('地区:', '#5FB878') + '全部',
                    url: $().lazyRule(() => {
                        clearVar('appDp.area');
                        refreshPage(true);
                        return 'hiker://empty'
                    }),
                    col_type: 'scroll_button'
                }];
                tarea_data = tarea_data.length > 1 ? tarea_head.concat(tarea_data).concat([{col_type: 'line'}]) : [];
                // log('地区');
                //----------------------------------------------
log(29)
                // log('语言');
                //---------------
                let tlang_data = Tools.unique2(now_type_extend.lang.split(',')).map((it) => {
                    return {
                        // title:it===getVar('appDp.lang',first_lang)?color(it,'#5FB878'):it,
                        title: it === getVar('appDp.lang', '') ? color(it, '#5FB878') : it,
                        url: $().lazyRule((it) => {
                            putVar('appDp.lang', it);
                            refreshPage(true);
                            return 'hiker://empty'
                        }, it),
                        col_type: 'scroll_button'
                    }
                });
                log(30)
                let tlang_head = [{
                    title: getVar('appDp.lang', '') === '' ? color('语言:全部', '#5FB878') : color('语言:', '#5FB878') + '全部',
                    url: $().lazyRule(() => {
                        clearVar('appDp.lang');
                        refreshPage(true);
                        return 'hiker://empty'
                    }),
                    col_type: 'scroll_button'
                }];
                tlang_data = tlang_data.length > 1 ? tlang_head.concat(tlang_data).concat([{col_type: 'line'}]) : [];
                //----------------------

                // log('年代');
                //---------------
                let tyear_data = Tools.unique2(now_type_extend.year.split(',')).map((it) => {
                    return {
                        // title:it===getVar('appDp.year',first_year)?color(it,'#5FB878'):it,
                        title: it === getVar('appDp.year', '') ? color(it, '#5FB878') : it,
                        url: $().lazyRule((it) => {
                            putVar('appDp.year', it);
                            refreshPage(true);
                            return 'hiker://empty'
                        }, it),
                        col_type: 'scroll_button'
                    }
                });
                log(31)
                let tyear_head = [{
                    title: getVar('appDp.year', '') === '' ? color('年代:全部', '#5FB878') : color('年代:', '#5FB878') + '全部',
                    url: $().lazyRule(() => {
                        clearVar('appDp.year');
                        refreshPage(true);
                        return 'hiker://empty'
                    }),
                    col_type: 'scroll_button'
                }];
                tyear_data = tyear_data.length > 1 ? tyear_head.concat(tyear_data).concat([{col_type: 'line'}]) : [];
                //------------------------------------
                // log('年代');
                d = d.concat(types_data).concat(tclass_data).concat(tarea_data).concat(tlang_data).concat(tyear_data);
            } //第一页才去请求分类
log(32)

            let index_url = ''; // 构造当前页面的地址信息
            let tpId = getVar('appDp.type_id',getVar('appDp.first_type_id'));//简写ID
            let tpCs = getVar('appDp.class',''); //简写类似
            let tpAr = getVar('appDp.area',''); //简写区域
            let tpLn = getVar('appDp.lang',''); //简写语言
            let tpYr = getVar('appDp.year',''); //简写年代
            api = changeRealApi(api);
            if (/api\.php\/app/.test(api)) {
                index_url = api + 'video?pg='+Npage+'&tid=' + tpId + '&class='+tpCs+'&area='+tpAr+'&lang='+tpLn+'&year='+tpYr+'&token=';
            } else if (/xgapp\.php\/v1/.test(api)){
                index_url = api + 'video?pg='+Npage+'&tid=' + tpId + '&class='+tpCs+'&area='+tpAr+'&lang='+tpLn+'&year='+tpYr;
            } else {
                index_url = api + '?type=' + tpId + '&class='+tpCs+'&area='+tpAr+'&lang='+tpLn+'&year='+tpYr+'&by=&page='+Npage+'&limit=9';
            }
            log(index_url);
            let rescode = fetch(index_url,global_headers);
            if (/检测中/.test(rescode)) {
                rescode = fetch(index_url + '&btwaf' + rescode.match(/btwaf(.*?)\"/)[1], global_headers);
            }
            try {
                let html = JSON.parse(rescode);
                d = d.concat(applistdata(html,api));
            }catch (e) {
                log(rescode);
            }
            // 每一页后面加空格可以区分翻页，但是数据就有空白，不够连续，所以还是注释好
            // d.push({col_type: 'line'});
            log(33)
        } catch (e) {log(e.message)}
        log(34)
    }
    setResult(d);
}

// 全局app接口替换函数,解决旧的app接口数据加密其实是换了新的api接口问题
function changeRealApi(api){
    if(/fantuan\.tv/.test(api)){
        api=api.replace("fantuan.tv","fantuan.wkfile.com");
    }
    return api
}

function applistdata(html,api){
    let d = [];//定义返回的数据列表
    let list = html.list||html.data.list||html.data;
    let head = /api\.php\/app|xgapp\.php\/v1/.test(api)?api+'video_detail?id=':api+'/detail?vod_id=';
    if(list.length<1){
        log('本次请求返回了:'+list.length+'条数据,源码为:\n'+JSON.stringify(html));
    }
    // function toMap(head){}
    d = list.map((it)=>{
        let link = head+it.vod_id+'&token='+extra_headers;
        return {
            title:it.vod_name,
            pic_url:it.vod_pic+'@Referer=',
            url:$("#immersiveTheme#"+link).rule(() => {
                let d = [];
                // 以前加载x5组件的地方,这里再也不用了,只保留个代码进行查看
                // d.push({
                //     title: '',
                //     desc: '255&&float',
                //     url: '',
                //     col_type: 'x5_webview_single'
                // });
                // refreshX5WebView('');
                log('影片详情及播放地址:'+MY_URL);
                let html = JSON.parse(getResCode());
                let index_url = MY_URL.match(/([\S]*?:\/\/[\S]*?)\//)[1];
                // log(index_url);
                // 加载此文件,获取appmovlist函数
                eval(fetch(getVar("appDp.js")));
                d = d.concat(appmovlist(html,index_url));
                setResult(d);
            }),
            desc: it.vod_remarks,
            col_type: 'movie_3_marquee'
        }
    });
    return d;
}

function appmovlist(html,myurl){//APP简介与选集
    // myurl 是网站的域名,接口api域名,html是源码
    const {color, small} = $.require("hiker://page/utiliy?rule=道长仓库Pro");
    let d = [];
    let conts = []; // 线路列表
    let data = html.data; //返回数据json
    if(data.vod_url_with_player){
        conts = data.vod_url_with_player
    }else if(data.vod_info&&data.vod_info.vod_url_with_player){
        conts = data.vod_info.vod_url_with_player;
    }else{
        conts = data.vod_play_list;
    }
    // 剧情简介大图
    let thumb = data.vod_info ? data.vod_info.vod_pic : data.vod_pic;
    let desc = data.vod_info ? data.vod_info.vod_content : data.vod_content;
    d.push({
        title: html.msg||'剧情简介：',
        desc: desc,
        pic_url: thumb,
        // url: thumb, // url打开图片,可以改为进入断插设置
        url: 'hiker://page/Route?rule=MyFieldᴰⁿ&type=设置#noHistory##noRecordHistory#',
        col_type: 'movie_1_vertical_pic_blur'
    });
    let selTitle = ['默认','断插魔改版'].map((it)=>{
        return it === getItem('appDp.play_mode','默认')?'👉'+it:it;
    });
    d.push({
        title: small('播放模式切换,当前为:')+color(getItem('appDp.play_mode','默认'),'#15ab21')+small(',点击图片配置断插'),
        col_type: 'text_1',
        url:$(selTitle).select(()=>{
            input = input.replace(/👉/g,'');
            setItem('appDp.play_mode',input);
            refreshPage(true);
            return 'toast://已切换播放模式为:'+input;
        })
    });
    function getLink(jxUrl,realUrl){
        let link = '';
        jxUrl = jxUrl||'';
        if(typeof(realUrl)=='undefined'){
            realUrl = '';
        }
        // log('传进来的解析地址:'+jxUrl);
        // 如果真实地址就是个直链
        if (/\.m3u8|\.mp4|obj\/tos/.test(realUrl)&&/^http|\?url=/.test(realUrl)) {//http开头的视频或者本身就是解析地址
            link = realUrl;
            if(/url=/.test(jxUrl)){
                link = jxUrl + realUrl;
            }
            // 如果真实地址不含签名就自动带解析
        }else if(!/sign=/.test(realUrl)){
            link = jxUrl + realUrl;
        }else{
            link = realUrl
        }
        //log(link);
        return link;
    }
    for(let i in conts){
        let list = conts[i].url.split("#"); //播放的官方地址列表
        let jxUrl = '';
        if (data.vod_url_with_player) {
            jxUrl = conts[i].parse_api; // 解析地址一般和url在同个json里
        }else if(data.vod_info && data.vod_info.vod_url_with_player){
            jxUrl = conts[i].parse_api; // 解析地址一般和url在同个json里
        }else{
            if (conts[i].player_info.parse2 && /=/.test(conts[i].player_info.parse2)) {
                jxUrl = conts[i].player_info.parse2.match(/.*?url=|.*?v=|.*?vid=/)[0].replace("..", ".").replace('jsonbs', '');
            } else if (conts[i].player_info.parse && /=/.test(conts[i].player_info.parse)) {
                jxUrl = conts[i].player_info.parse.match(/.*?url=|.*?v=|.*?vid=/)[0].replace("..", ".");
            } // 其他情况默认就是空的
        }
        jxUrl = jxUrl||''; // 如果null就设置为字符串
        if(typeof (jxUrl)=='string'&&!/^http/.test(jxUrl)&&jxUrl.startsWith('//')){
            jxUrl = 'https:' + jxUrl; //解析地址自动补全https前缀
        }
        let ptab = ''; //播放线路名称
        if (data.vod_url_with_player||(data.vod_info && data.vod_info.vod_url_with_player)) {
            ptab = conts[i].name;
        } else {
            ptab = conts[i].from;
        }
        let nowCount = parseInt(i)+1; //当前线路序号
        // log('线路:'+nowCount+'的解析地址:'+jxUrl);
        d.push({
            title: ptab + ' 🔗' + '当前线路:'+nowCount + '/总线路数:' + conts.length,
            col_type: 'text_1',
            url:$().lazyRule((jxUrl)=>{
                let selTitle = ['默认','断插魔改版','正序','逆序','复制解析地址','免解析'].map((it)=>{
                    return (it === getItem('appDp.play_mode','默认')||it === getItem('appDp.play_order','正序')||it===getItem('appDp.need_jx','要解析'))?'👉'+it:it;
                });
                return $(selTitle,2).select((jxUrl)=>{
                    input = input.replace(/👉/g,'');
                    if(/默认|断插/.test(input)){
                        setItem('appDp.play_mode',input);
                        return 'toast://已切换播放模式为:'+input;
                        // refreshPage(true); // 动态切换免去刷新
                    }else if(/正序|逆序/.test(input)){
                        setItem('appDp.play_order',input);
                        refreshPage(true);
                        return 'toast://已切换选集顺序为:'+input;
                    }else if(/复制解析地址/.test(input)){
                        if(typeof(jxUrl)==='string'&&/^http/.test(jxUrl)){
                            copy(jxUrl);
                            return 'toast://成功复制解析地址:\n'+jxUrl
                        }else{
                            return 'toast://貌似这条线路没有解析地址!'
                        }
                    }else if(/解析/.test(input)){
                        if(getItem('appDp.need_jx','免解析')==='免解析'){
                            setItem('appDp.need_jx','要解析');
                        }else{
                            setItem('appDp.need_jx','免解析');
                        }
                        return 'toast://已设置默认播放需要解析为:'+getItem('appDp.need_jx','免解析')
                    }
                    else{
                        return 'toast://点什么点,这是标志符呢!'
                    }
                },jxUrl)
                // return 'toast://点我做什么?\n你以为可以切换正序逆序吗?'
            },jxUrl)
        });
        if(getItem('appDp.play_order','正序')==='逆序'){
            list = list.reverse();
        }

        for (let j in list) {
            let link = ''; // 每集的播放地址
            if (data.vod_url_with_player) {
                link = getLink(jxUrl,list[j].split("$")[1]);
            }else if (data.vod_info && data.vod_info.vod_url_with_player) {
                link = getLink(jxUrl,list[j].split("$")[1]);
                //单独处理cokemv,好大的面子啊!
                if (!/http/.test(link)&&!jxUrl&&/cokemv/.test(myurl)) {
                    let src_url = 'https://cokemv.me/voddetail/'+data.vod_info.vod_id+'.html';
                    let headers = {headers: {"User-Agent": MOBILE_UA}};
                    let back_code = fetch(src_url,headers);
                    let tablists = [];
                    try {
                        back_code = pdfa(back_code,'.tab-content,0&&a');
                        tablists = back_code.map((it)=>{
                            return 'https://cokemv.me'+pdfh(it,'a&&href');
                        })
                    }catch (e) {
                        log(e.message);
                    }
                    link = tablists.length>i?tablists[i]:'https://cokemv.me/vodplay/'+data.vod_info.vod_id+'-'+(i+1)+'-1.html';
                    // log(link);
                }
                //---这部分代码后面干掉
            }else {
                link = getLink(jxUrl,list[j].split("$")[1]);
            }

            let title = list[j].split("$")[0]; // 选集名称
            let realUrl = list[j].split("$")[1] //原地址
            // 设置选集渲染样式，主要解决集数名称只有1位的问题，比如 1,2,3,用flex_button就太小了
            let col_type = list.length <= 4?'text_2':(isNaN(title) ? 'flex_button' : 'text_5');
            // let col_type = 'flex_button';
            d.push({
                title:title,
                col_type:col_type,
                url: playSrc(ptab, link, myurl,realUrl),
                extra:{
                    blockRules: ['baidu.*.png', '.jpg','.mp3','.mp4','.m3u8','.flv','.avi','.3gp','.mpeg','.wmv','.mov','.rmvb','.gif','.jpg','.jpeg','.png','.ico','.svg'],
                }
            });
        }

    }
    return d;
}

function tvlistdata(murl,html){//TV列表解析
    let d = [];
    let list = html.data;
    for (let i in list) {
        let tlist = list[i];
        let title = tlist.title;
        let img = tlist.pic;
        let url = tlist.nextlink;
        url = url.startsWith('http') ? url : murl + '?ac=detail&ids=' + url;
        let desc = tlist.state;
        d.push({
            title: title,
            pic_url: img + '@Referer=',
            url: $("#immersiveTheme#"+url).rule(() => {
                let d = [];
                let html = JSON.parse(getResCode());
                let myurl = MY_URL.match(/([\S]*?:\/\/[\S]*?)\//)[1];
                eval(fetch(getVar("appDp.js")));
                d = d.concat(tvmovlist(html,myurl));
                setResult(d);
            }),
            desc: desc,
            col_type: 'movie_3_marquee'
        });
    }
    return d
}


function tvmovlist(html,myurl){//TV简介与选集
    // myurl 是网站的域名,接口api域名,html是源码
    const {color, small} = $.require("hiker://page/utiliy?rule=道长仓库Pro");
    let d=[];
    let tabs = Object.keys(html.videolist);
    let thumb = html.img_url;
    d.push({
        title: html.msg||'剧情简介：',
        desc: html.intro,
        pic_url: thumb,
        // url: thumb, // url打开图片,可以改为进入断插设置
        url: 'hiker://page/Route?rule=MyFieldᴰⁿ&type=设置#noHistory##noRecordHistory#',
        col_type: 'movie_1_vertical_pic_blur'
    });
    let selTitle = ['默认','断插魔改版'].map((it)=>{
        return it === getItem('appDp.play_mode','默认')?'👉'+it:it;
    });
    d.push({
        title: small('播放模式切换,当前为:')+color(getItem('appDp.play_mode','默认'),'#15ab21')+small(',点击图片配置断插'),
        col_type: 'text_1',
        url:$(selTitle).select(()=>{
            input = input.replace(/👉/g,'');
            setItem('appDp.play_mode',input);
            refreshPage(true);
            return 'toast://已切换播放模式为:'+input;
        })
    });
    function getLink(jxUrl,realUrl){
        let link = '';
        jxUrl = jxUrl||'';
        if(typeof(realUrl)=='undefined'){
            realUrl = '';
        }
        // log('传进来的解析地址:'+jxUrl);
        // 如果真实地址就是个直链
        if (/\.m3u8|\.mp4|obj\/tos/.test(realUrl)&&/^http|\?url=/.test(realUrl)) {//http开头的视频或者本身就是解析地址
            link = realUrl;
            if(/url=/.test(jxUrl)){
                link = jxUrl + realUrl;
            }
            // 如果真实地址不含签名就自动带解析
        }else if(!/sign=/.test(realUrl)){
            link = jxUrl + realUrl;
        }else{
            link = realUrl
        }
        //log(link);
        return link;
    }

    for (let i in tabs) {
        let list = html.videolist[tabs[i]];
        let jx = list.filter(it=>it.jx);
        let jxUrl = jx.length>0?jx[0].url.split('=http')[0]+'=':'';
        let ptab = tabs[i];
        let nowCount = parseInt(i)+1; //当前线路序号
        // log('线路:'+nowCount+'的解析地址:'+jxUrl);

        d.push({
            title: ptab + ' 🔗' + '当前线路:'+nowCount + '/总线路数:' + tabs.length,
            col_type: 'text_1',
            url:$().lazyRule((jxUrl)=>{
                let selTitle = ['默认','断插魔改版','正序','逆序','复制解析地址','免解析'].map((it)=>{
                    return (it === getItem('appDp.play_mode','默认')||it === getItem('appDp.play_order','正序')||it===getItem('appDp.need_jx','要解析'))?'👉'+it:it;
                });
                return $(selTitle,2).select((jxUrl)=>{
                    input = input.replace(/👉/g,'');
                    if(/默认|断插/.test(input)){
                        setItem('appDp.play_mode',input);
                        return 'toast://已切换播放模式为:'+input;
                        // refreshPage(true); // 动态切换免去刷新
                    }else if(/正序|逆序/.test(input)){
                        setItem('appDp.play_order',input);
                        refreshPage(true);
                        return 'toast://已切换选集顺序为:'+input;
                    }else if(/复制解析地址/.test(input)){
                        if(typeof(jxUrl)==='string'&&/^http/.test(jxUrl)){
                            copy(jxUrl);
                            return 'toast://成功复制解析地址:\n'+jxUrl
                        }else{
                            return 'toast://貌似这条线路没有解析地址!'
                        }
                    }else if(/解析/.test(input)){
                        if(getItem('appDp.need_jx','免解析')==='免解析'){
                            setItem('appDp.need_jx','要解析');
                        }else{
                            setItem('appDp.need_jx','免解析');
                        }
                        return 'toast://已设置默认播放需要解析为:'+getItem('appDp.need_jx','免解析')
                    }
                    else{
                        return 'toast://点什么点,这是标志符呢!'
                    }
                },jxUrl)
                // return 'toast://点我做什么?\n你以为可以切换正序逆序吗?'
            },jxUrl)
        });
        if(getItem('appDp.play_order','正序')==='逆序'){
            list = list.reverse();
        }

        for (let j in list) {
            // let srcurl = list[j].url;
            let title = list[j].title;
            let realUrl = !jxUrl?list[j].url:list[j].url.replace(jxUrl,'') //原地址
            let link = getLink(jxUrl,realUrl);
            // 设置选集渲染样式，主要解决集数名称只有1位的问题，比如 1,2,3,用flex_button就太小了
            let col_type = list.length <= 4?'text_2':(isNaN(title) ? 'flex_button' : 'text_5');
            // let col_type = 'flex_button';
            d.push({
                title:title,
                col_type:col_type,
                url: playSrc(ptab, link, myurl,realUrl,true),
                extra:{
                    blockRules: ['baidu.*.png', '.jpg','.mp3','.mp4','.m3u8','.flv','.avi','.3gp','.mpeg','.wmv','.mov','.rmvb','.gif','.jpg','.jpeg','.png','.ico','.svg'],
                }
            });
        }//选集循环结束
    }//线路循环结束
    return d;
}


function appDpSearch(){//APP搜索代码
    let d=[];
    //设置搜索线程
    let search_mode = getItem('appDp.search_mode','聚合');
    let search_xc = getItem('appDp.search_xc','10');

    //设置超时时间，越小越快，单位毫秒
    let timeout = parseInt(getItem("appDp.search_timeout","5000"));
    let key = MY_URL.split('$$$')[1]; //关键字
    let num = MY_URL.split('$$$')[2]; // 页数
    let le = parseInt(num * parseInt(search_xc));
    if (search_mode === '列表') {
        setPageTitle(key + ' 的搜索结果')
    }
    // var html = JSON.parse(fetch('https://inmemory.coding.net/p/InMemory/d/MBrowser/git/raw/master/AppFile/APP影视列表', {}));
    // var dlist = html.data; //搜索app
    let load_file = getVar("appDp.now_file")?getVar("appDp.now_file"):'m点佬.txt';
    let html = fetch(getVar("appDp.bs")+load_file);
    let puh = [];
    let arr = html.indexOf('http') > -1 ? html.match(/#[\s\S]*?#/g) : base64Decode(html).match(/#[\s\S]*?#/g);
    for (let i in arr) {
        let tabs = arr[i].match(/#.*?[\s]/g)[0].split('#')[1].replace(/\n/, ''); // app所属类
        let list = arr[i].match(/[\S]*?,.*?[\s]/g);
        if (search_mode === '列表') {
            d.push({
                title: MY_TYPE === "home" ? tabs + " 选择一个项目查看 ““" + key + "”” 的搜索结果" : tabs + " 选择一个项目查看 " + key + " 的搜索结果",
                col_type: 'text_1'
            });
        }
        if(getItem('appDp.random','1')==='1'){
            list = randomSort(list);
        }
        for (let j in list) {
            let res = list[j].split(',');
            let title = res[0]; // app名称
            let link = res[1]; // app接口地址
            let img = res.length >= 3 ? res[2].replace('\n', '') : ''; //app图标
            let hmurl = ''; // 搜索链接

            if (/APP影视/.test(tabs)) {
                if (/api\.php\/app\//.test(link)) {
                    hmurl = link + 'search?pg=fypage&text=' + key + '&token=';
                } else if (/xgapp\.php\/v1\//.test(link)) {
                    hmurl = link + 'search?pg=fypage&text=' + key;
                } else {
                    hmurl = link + '?page=fypage&limit=10&wd=' + key;
                }
            } else if (/TV影视/.test(tabs)) {
                if (/19jx|293ys|zhaikanys|ji\-ding\-he|phoebe|yunbo\.bxin|lanrentk|hetaoys/.test(link)) {
                    hmurl = link + '?ac=list&zm=' + key + '&page=fypage';
                } else {
                    hmurl = link + '?ac=list&wd=' + key + '&page=fypage';
                }
            }
            if (search_mode === '列表') {
                d.push({
                    title: title,
                    img: img,
                    col_type: 'icon_round_small_4',
                    url: $('hiker://empty#x#' + hmurl + '#x#' + link + '#x#' + tabs + '#x#' + key + '#x#').rule(() => {
                        eval(fetch(getVar('appDp.js')));
                        appDpSearchEj();
                    }),
                });
            } else {
                puh.push({
                    title: title,
                    url: hmurl.replace(/fypage/g, '1'),
                    link: link,
                    type: tabs
                });
            }
        } //for j
    } // for i 遍历分类结束

    log('遍历结束,搜索模式为：'+search_mode);
    if (search_mode === '聚合') {
        let Data = [];
        let Tit = [];
        for (let j = le - search_xc; j < le; j++) {
            if (j < puh.length) {
                Data.push({
                    url: puh[j].url,
                    options: {
                        headers: {
                            "User-Agent": "Dart/2.13 (dart:io)"
                        },
                        timeout: timeout
                    }
                });
                Tit.push({
                    tit: puh[j].title,
                    typnm: puh[j].type,
                    link: puh[j].link
                });
            } //if
        } //for j

        //---代码分界线----
        if (Data !== '') {
            let bhtml = batchFetch(Data);
            for (let k in bhtml) {
                let html = bhtml[k];
                try {
                    html = html.substring(0, 2) === '\r\n' ? html.replace('\r\n', '') : html;
                } catch (e) {log(e.message)}

                if (/btwaf/.test(html)) {
                    html = fetch(Data[k].url + '&btwaf' + html.match(/btwaf(.*?)\"/)[1], {});
                }
                if (typeof(html)=='undefined'|| html == null ||html === ""|| html.startsWith('error')|| !html.startsWith('{')) {
                    d.push({
                        title: Tit[k].tit + ' ' + '未搜索到，点击访问原网页',
                        url: Data[k].url + `@lazyRule=.js:input.split(';')[0]`,
                        col_type: 'text_1'
                    });
                } else if (html.length < 30) {
                    d.push({
                        title: Tit[k].tit + ' ' + '返回数据不完整，点击访问原网页',
                        url: Data[k].url + `@lazyRule=.js:input.split(';')[0]`,
                        col_type: 'text_1'
                    });
                } else {
                    html = JSON.parse(html||'{}');
                    let typet = Tit[k].typnm;
                    let tdomin = Tit[k].link;
                    let list = html.list||html.data.list||html.data||[];
                    if (list.length < 1) {
                        d.push({
                            title: Tit[k].tit + ' ' + '列表小于1，无法展示，点击访问原网页',
                            url: Data[k].url + `@lazyRule=.js:input.split(';')[0]`,
                            col_type: 'text_1'
                        });
                    } else {
                        for (let i in list) {
                            let title = '';
                            let pic = '';
                            let vid = '';
                            let rem = '';
                            if (/TV影视/.test(typet)) {
                                title = list[i].title;
                                pic = list[i].pic;
                                vid = list[i].nextlink;
                                rem = list[i].state;
                            } else if (/APP影视/.test(typet)) {
                                if (/api\.php\/app\//.test(tdomin)) {
                                    title = list[i].vod_name;
                                    pic = list[i].vod_pic;
                                    vid = tdomin + 'video_detail?id=' + list[i].vod_id + '&token=';
                                    rem = list[i].vod_remarks;
                                } else if (/xgapp\.php\/v1\//.test(tdomin)) {
                                    title = list[i].vod_name;
                                    pic = list[i].vod_pic;
                                    vid = tdomin + 'video_detail?id=' + list[i].vod_id;
                                    rem = list[i].vod_remarks;
                                } else {
                                    title = list[i].vod_name;
                                    pic = list[i].vod_pic;
                                    vid = tdomin + '/detail?vod_id=' + list[i].vod_id + '&token=';
                                    rem = list[i].vod_remarks;
                                }
                            }

                            d.push({
                                title: MY_TYPE === "home" ? title.replace(key, '““' + key + '””') + '\n' + rem : title + rem,
                                pic_url: pic + '@Referer=',
                                url: $(vid+'#immersiveTheme#;get;utf-8;{User-Agent@Dart/2.13 (dart:io)}').rule((typet,title) => {
                                    let d = [];
                                    let html = JSON.parse(getResCode());
                                    let murl = MY_URL.match(/([\S]*?:\/\/[\S]*?)\//)[1];
                                    d.push({
                                        title: '',
                                        desc: '255&&float',
                                        url: '',
                                        col_type: 'x5_webview_single'
                                    });
                                    setPageTitle(title);
                                    eval(fetch(getVar('appDp.js')));
                                    if (/APP影视/.test(typet)) {
                                        d = d.concat(appmovlist(html,murl));
                                    } else if (/TV影视/.test(typet)) {
                                        d = d.concat(tvmovlist(html,murl));
                                    }
                                    setResult(d);
                                }, typet,title),
                                desc: typet + ' => ' + Tit[k].tit,
                                col_type: 'movie_1_vertical_pic'
                            });
                        } //for i
                    } //if list.length
                }
            } //for k bhtml.length
        }
    }
    setResult(d);
}

function appDpSearchEj(){//app搜索二级，无返回值
    let d = [];
    let spl = getResCode().split('#x#');
    let typet = spl[3];
    let tdomin = spl[2];
    let key = spl[4];
    let bhtml;
    let headers = {
        headers: {
            "User-Agent": "Dart/2.13 (dart:io)"
        }
    };
    if (/vipmv/.test(tdomin)) {
        bhtml = request(spl[1]);
    } else {
        bhtml = fetch(spl[1],headers);
    }
    try {
        bhtml = bhtml.startsWith('\r\n') ? bhtml.replace('\r\n', '') : bhtml;
    } catch (e) {log(e.message)}
    if (/btwaf/.test(bhtml)) {
        bhtml = fetch(spl[1] + '&btwaf' + bhtml.match(/btwaf(.*?)\"/)[1], {});
    }

    if (typeof(bhtml)=='undefined'|| bhtml == null ||bhtml === ""|| bhtml.startsWith('error')|| !bhtml.startsWith('{')) {
        d.push({
            title: '未搜索到相关资源，点击访问原网页',
            url: spl[1] + `@lazyRule=.js:input.split(';')[0]`,
            col_type: 'text_1'
        });
    } else if (bhtml.length < 30) {
        d.push({
            title: '返回数据不完整，点击访问原网页',
            url: spl[1] + `@lazyRule=.js:input.split(';')[0]`,
            col_type: 'text_1'
        });
    } else {
        let html = JSON.parse(bhtml);
        let list=html.list||html.data.list||html.data||[];
        if (list.length < 1) {
            d.push({
                title: '未搜索到，点击访问原网页',
                url: spl[1] + `@lazyRule=.js:input.split(';')[0]`,
                col_type: 'text_1'
            });
        } else {
            for (let i in list) {
                let title;
                let pic;
                let vid;
                let rem;
                // let con;
                if (/APP影视/.test(typet)) {
                    if (/api\.php\/app\//.test(tdomin)) {
                        title = list[i].vod_name;
                        pic = list[i].vod_pic;
                        vid = tdomin + 'video_detail?id=' + list[i].vod_id + '&token=';
                        rem = list[i].vod_remarks;
                        //con=list[i].type.type_des;
                    } else if (/xgapp.php\/v1\//.test(tdomin)) {
                        title = list[i].vod_name;
                        pic = list[i].vod_pic;
                        vid = tdomin + 'video_detail?id=' + list[i].vod_id;
                        rem = list[i].vod_remarks;
                        //con=list[i].type.type_des;
                    } else {
                        title = list[i].vod_name;
                        pic = list[i].vod_pic;
                        vid = tdomin + '/detail?vod_id=' + list[i].vod_id + '&token=';
                        rem = list[i].vod_remarks;
                        //con=list[i].type.type_des;
                    }
                } else if (/TV影视/.test(typet)) {
                    title = list[i].title;
                    pic = list[i].pic;
                    //vid=tdomin+'/detail?vod_id='+list[i].nextlink+'&rel_limit=10';
                    vid = list[i].nextlink;
                    rem = list[i].state;
                    //con=list[i].state;
                }
                let link=vid+';get;utf-8;{User-Agent@Dart/2.13 (dart:io)}';
                let search_title = title.replace(key, '““' + key + '””');

                d.push({
                    title: search_title,
                    pic_url: pic + '@Referer=',
                    url: $('#immersiveTheme#'+link).rule((typet,title) => {
                        let d = [];
                        let html = JSON.parse(getResCode());
                        d.push({
                            title: '',
                            desc: '255&&float',
                            url: '',
                            col_type: 'x5_webview_single'
                        });
                        setPageTitle(title);
                        refreshX5WebView('');
                        let myurl = MY_URL.match(/([\S]*?:\/\/[\S]*?)\//)[1];
                        eval(fetch(getVar('appDp.js')));
                        if (/APP影视/.test(typet)) {
                            d = d.concat(appmovlist(html,myurl));
                        } else if (/TV影视/.test(typet)) {
                            d = d.concat(tvmovlist(html,myurl));
                        }
                        setResult(d);
                    }, typet,title),
                    //content:rem,
                    desc: rem,
                    col_type: 'movie_1_vertical_pic'
                });
            } //for i
        } //else list.length
    }
    setResult(d);
}


// 播放视频
function playSrc(ptab, link, myurl,realUrl,nolazy){
    nolazy = nolazy||false;
    if(typeof(link)=='undefined'||!link){
        return 'toast://播放个鸡毛,地址都没有!'
    }
    function reChange(link){
        if (/cat\.wkfile\.com\/m3u8/.test(link)){
            link+=";{Referer@https://fantuan.tv}"
        }
        return link;
    }
    // 参数 线路标志如爱奇艺腾讯哔哩哔哩,完整播放地址,数据接口域名,不带解析的源地址
    return $().lazyRule((ptab, link, myurl,realUrl,reChange,Gheaders,nolazy) => {
        // let host = realUrl.match(/\.(.*?)\//)[1];
        // let canDo = getItem('appDp.play_mode','默认')==='断插'&&/qq\.com|iqiyi\.com.com|youku\.com|alizy|mgtv\.com|bilibili\.com|sohu\.com|ixigua\.com|pptv\.com|miguvideo\.com|le\.com|1905\.com|fun\.tv/.test(host);
        let canDo = /断插/.test(getItem('appDp.play_mode','默认'));
        if(canDo){
            log('正在断插魔改版解析...');
            eval("var config =" + fetch("hiker://files/cache/MyParseSet.json"));
            eval(fetch(config.cj));
            // 加入超时设置，建议在首页设置
            return aytmParse(reChange(realUrl),'',parseInt(getItem('appDp.timeout','5000')),link)
        }else{
            // 通用仓库免嗅探。切换手机UA
            // let headers = {headers: {"User-Agent": MOBILE_UA}};
            log('正在默认解析...');
            if(getItem('appDp.need_jx','免解析')==='免解析'){
                const {isVideo} = $.require('hiker://page/globalParse?rule=道长仓库Pro');
                //log(isVideo(realUrl));
                if(typeof(isVideo(realUrl))==="string"){
                    link = realUrl;
                }
            }
            if(nolazy){
                return link+';get;utf-8;{User-Agent@Dart/2.13 (dart:io)}'
            }
            let testcode = fetch(link,
                {headers: {"User-Agent":MOBILE_UA},timeout:800}); //测试取跳转解析的源码
            // log(testcode);
            if (/检测中/.test(testcode)&&/&btwaf=/.test(testcode)) {
                let cookie = JSON.parse(request(link,{withHeaders:true})).headers["set-cookie"][0];
                let json = request(link,{headers:{Host:"json.1r.ee",cookie:cookie.substr(0, cookie.length - 1),accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}});
                try {
                    let url = JSON.parse(json).url;
                    if(/^http/.test(url)){
                        if(/lecloud\.com|bilivideo\.com/.test(url)){
                            url+=";{Referer@https://www.bilibili.com/&&User-Agent@Mozilla/5.0}";
                        }else if(/mgtv\.com|ixigua\.com/.test(url)){
                            url+=";{User-Agent@Mozilla/5.0}";
                        }
                        return url
                    }else{
                        return 'toast://未知的东西:\n'+url
                    }
                }
                catch (e) {
                    log('本道无能为力，跳转验证类解析地址:'+link+'\n'+e.message);
                    return 'toast://江湖有缘再见,请切换解析再说,具体看日志'
                }
            }
            let playUrl = reChange(link);
            //log("playUrl:"+playUrl);
            const {lazyParse} = $.require('hiker://page/globalParse?rule=道长仓库Pro');
            return lazyParse(playUrl);
        }
        //动态解析代码结束
    }, ptab, link, myurl,realUrl,reChange,Gheaders,nolazy);
}

String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
function convertDate(path){//数据转换处理m浏览器兼容
    let back = fetch(path,{});
    try {
        back = JSON.parse(back);
        let datas = back.data;
        let applists = '';
        for(let i in datas){
            let data = datas[i];
            let text = data.list.map((it)=>{return [it.title,it.url,it.img].join(',')});
            text = '#'+data.title+'\n'+text.join('\n')+'\n#\n';
            applists+=text;
        }
        return applists.trim()
    }catch (e) {
        // log(e.message);
        return back
    }
}

function uploadFiles(withExist){
    // log('进入拉取txt方法,判断文件是否存在:'+withExist);
    withExist=withExist||1;
    let files={
        "道长app.txt":getVar('appDp.data_url')+"5",
        "m点佬.txt":"https://inmemory.coding.net/p/InMemory/d/MBrowser/git/raw/master/AppFile/APP影视列表"
    };
    for(let key in files){
        if(withExist===1){
            if(!fileExist(getVar('appDp.bs')+key)||!fetch(getVar('appDp.bs')+key)){
                log('缺少:'+key+',开始拉取:'+files[key]);
                let filecode=/\.txt/.test(key)?convertDate(files[key]):fetch(files[key]);
                if(filecode&&filecode.length>200){
                    writeFile(getVar('appDp.bs')+key,filecode);
                }else{
                    log(filecode);
                }
            }
        }else{
            let filecode=/\.txt/.test(key)?convertDate(files[key]):fetch(files[key]);
            if(filecode&&filecode.length>200){
                writeFile(getVar('appDp.bs')+key,filecode);
            }else{
                log(filecode);
            }
        }
    }
}

//APP预处理预处理代码
function apppre() {
    uploadFiles();//不传参数
    // upOtherApps();//定时间隔1天自动同步m代码
    // check_house();//仓库检测
}